home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Personal Computer World 2009 February
/
PCWFEB09.iso
/
Software
/
Resources
/
Chat & Communication
/
Digsby build 37
/
digsby_setup.exe
/
lib
/
common
/
UpdateMixin.pyo
(
.txt
)
< prev
Wrap
Python Compiled Bytecode
|
2008-10-13
|
3KB
|
80 lines
# Source Generated with Decompyle++
# File: in.pyo (Python 2.5)
from logging import getLogger
log = getLogger('updatemixin')
info = log.info
from Protocol import StateMixin
from util import Delegate, RepeatTimer, get
nothing = lambda *a, **k: pass
class UpdateMixin(StateMixin):
updatefreq = 300
def __init__(self, updatefreq = None, *a, **k):
StateMixin.__init__(self, *a, **k)
if updatefreq is not None:
try:
updatefreq = int(updatefreq)
except ValueError:
pass
if updatefreq < 1:
updatefreq = 60
self.updatefreq = max(updatefreq, 15)
self.on_connect = Delegate()
self.on_disable = Delegate()
def disconnect(self):
self.timer.stop()
def update_now(self):
raise NotImplementedError
def get_options(self):
return (dict,)((lambda .0: for a in .0:
(a, getattr(self, a)))(('enabled', 'updatefreq')))
def get_enabled(self):
return get(self, '_enabled', False)
def set_enabled(self, value):
if not hasattr(self, '_enabled'):
self.change_reason(self.Reasons.NONE)
info('%s creating a timer with update frequency %s', self, self.updatefreq)
self.timer = RepeatTimer(int(self.updatefreq), self.update_now)
self.timer.start()
self.timer.stop()
if get(self, 'on_connect', None) is not None and self.update_now not in self.on_connect:
self.on_connect += self.update_now
if value:
info('enabling timer for %s', self)
if self.OFFLINE:
get(self, 'Connect', nothing)()
self.timer.reset(int(self.updatefreq))
self._enabled = value
elif hasattr(self, '_enabled'):
if not self.OFFLINE:
get(self, 'Disconnect', nothing)()
info('stopping timer for %s', self)
self.timer.stop()
get(self, 'on_disable', nothing)()
self._enabled = value
enabled = property(get_enabled, set_enabled)